// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import '@/plugins/vantUI' // 按需加载vantUI组件
import Vue from 'vue'
import App from './App'
import './assets/styles/common.less'
import router from './router'
import store from './store'
// import * as echarts from 'echarts' // 全量引入echarts
// import  {default as echarts} from '@/plugins/initEcharts' // 按需引入echarts
import { VJsonGet } from '@/utils/common'
import '@/utils/dateUtils'
import '@/utils/nativeUtils'
import '@/utils/parameter'
import '@/utils/rem'
import { cookieSet } from '@/utils/storage'
import '@/utils/typeUtils'
// import '@/utils/errorHandler'

import moment from 'moment'
moment.locale('zh-cn')

// mockjs
// if (process.env.NODE_ENV !== 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// 隐藏构建类型提示
Vue.config.productionTip = false
Vue.prototype.$sensors = window.sensors

// 根据url获取参数对象
const obj = {}
window.location.href.replace(/([^?&=]+)=([^&]+)/g, (_, k, v) => (obj[k] = v))
console.log('接收参数：', obj)

// platform 微信必传wechat app目前不传
store.commit('SET_PLATFORM', VJsonGet('', obj, 'platform'))
// 不同平台提交不同的公共报文参数
const platform = VJsonGet('', obj, 'platform')
if (platform === 'wechat') {
  store.commit('SET_APPCHANNELCODE', 'JKWX')
  store.commit('SET_CHANNELCODE', 'JKWX1')
} else {
  store.commit('SET_APPCHANNELCODE', 'JKAP')
  store.commit('SET_CHANNELCODE', 'JKAP1')
}
// token为必传参数 userId非必传 白名单接口可都不传但接口必传uniqueId
cookieSet('App-token', VJsonGet('', obj, 'token'))
cookieSet('App-userId', VJsonGet('', obj, 'userId'))

if (process.env.NODE_ENV === 'staging') {
  console.log('当前版本：', process.env.BUILDVERSION)
}

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  render: (h) => h(App)
})
